﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Course2
{
    /// <summary>
    /// 实现集合
    /// </summary>
    internal class MyList1 : IList<string>
    {
        public string this[int index] { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }

        public int Count => throw new NotImplementedException();

        public bool IsReadOnly => throw new NotImplementedException();

        public void Add(string item)
        {
            throw new NotImplementedException();
        }

        public void Clear()
        {
            throw new NotImplementedException();
        }

        public bool Contains(string item)
        {
            throw new NotImplementedException();
        }

        public void CopyTo(string[] array, int arrayIndex)
        {
            throw new NotImplementedException();
        }

        public IEnumerator<string> GetEnumerator()
        {
            throw new NotImplementedException();
        }

        public int IndexOf(string item)
        {
            throw new NotImplementedException();
        }

        public void Insert(int index, string item)
        {
            throw new NotImplementedException();
        }

        public bool Remove(string item)
        {
            throw new NotImplementedException();
        }

        public void RemoveAt(int index)
        {
            throw new NotImplementedException();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            throw new NotImplementedException();
        }
    }

    public class MyList2 : IList<string>
    {
        private List<string> _target;

        public string this[int index] { get => ((IList<string>)_target)[index]; set => ((IList<string>)_target)[index] = value; }

        public int Count => ((ICollection<string>)_target).Count;

        public bool IsReadOnly => ((ICollection<string>)_target).IsReadOnly;

        public void Add(string item)
        {
            ((ICollection<string>)_target).Add(item);
        }

        public void Clear()
        {
            ((ICollection<string>)_target).Clear();
        }

        public bool Contains(string item)
        {
            return ((ICollection<string>)_target).Contains(item);
        }

        public void CopyTo(string[] array, int arrayIndex)
        {
            ((ICollection<string>)_target).CopyTo(array, arrayIndex);
        }

        public IEnumerator<string> GetEnumerator()
        {
            return ((IEnumerable<string>)_target).GetEnumerator();
        }

        public int IndexOf(string item)
        {
            return ((IList<string>)_target).IndexOf(item);
        }

        public void Insert(int index, string item)
        {
            ((IList<string>)_target).Insert(index, item);
        }

        public bool Remove(string item)
        {
            return ((ICollection<string>)_target).Remove(item);
        }

        public void RemoveAt(int index)
        {
            ((IList<string>)_target).RemoveAt(index);
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return ((IEnumerable)_target).GetEnumerator();
        }
    }

    /// <summary>
    /// 迭代器
    /// </summary>
    public class Mylist3 : IEnumerable,IEnumerator
    {
        public object Current => throw new NotImplementedException();

        public IEnumerator GetEnumerator()
        {
            throw new NotImplementedException();
        }

        public bool MoveNext()
        {
            throw new NotImplementedException();
        }

        public void Reset()
        {
            throw new NotImplementedException();
        }
    }

}
